<!DOCTYPE html>
<html>
	<head lang="en">
		<meta charset="UTF-8">
		<title>课工场论坛列表</title>
		<link href="bbs.css" rel="stylesheet">
		<script>
			function crate() {
						let postlist = document.querySelector(".bbs section ul");
						let title = document.querySelector(".post .title").value;
						let ban = document.querySelector(".sel").value;
						if (title == "") {
							alert("不能发布空标题");
							return;
						} else if (ban == "请选择版块") {
							alert("请选择发贴主题");
							return;
						}
						let li = document.createElement("li");
						postlist.appendChild(li);
						let div = document.createElement("div");
						li.appendChild(div);
						let img = document.createElement("img");
						let a=Math.round(Math.random()*4);
						alert(a);
						img.src = "课工场论坛图/"+"tou"+'0+a'+".jpg";
						div.appendChild(img);
						let h1 = document.createElement("h1");
						h1.innerHTML = title;
						li.appendChild(h1);
						let p = document.createElement("p");
						li.appendChild(p);
						let span = document.createElement("span");
						span.innerHTML = "版块：" + ban;
						p.appendChild(span);
						span = document.createElement("span");
						span.innerHTML = "发帖时间：" + new Date().toLocaleString();
						p.appendChild(span);
						noshow();
					}
			
					function find() {
			
			
						return title;
					}
			
					function send() {
						let post = document.querySelector(".post");
						let dis = document.defaultView.getComputedStyle(post, null).display;
						post.style.display = "block";
					}
			
					function nosend() {
						let post = document.querySelector(".post");
						post.style.display = "none";
					}
		</script>
	</head>
	<body>
		<div class="bbs">
			<header id="d1" ><span onclick="send()">我要发帖</span></header>
			<section>
				<ul id="postList">
					<li>
						<div><img src="课工场论坛图/tou02.jpg"></div>
						<h1>ggggg</h1>
						<p><span>版块：新手报到</span><span>发表时间：2019-11-18 17:28</span></p>
					</li>
					<li>
						<div>
							<img src="课工场论坛图/tou01.jpg"></div>
						<h1>ddddd</h1>
						<p><span>版块：新课来了</span><span>发表时间：2019-11-18 17:27</span></p>
					</li>
				</ul>
			</section>
			<div class="post">
				<input class="title" placeholder="请输入标题（1-50个字符）">
				所属版块：<select class="sel">
					<option>请选择版块</option>
					<option >电子书籍</option>
					<option >新课来了</option>
					<option >新手报到</option>
					<option >职业规划</option>
				</select>
				<textarea class="content"></textarea>
				<input class="btn" value="发布" onclick="crate()">
			</div>
		</div>
	</body>
</html>
